package test.serverframe.armc.server.manager.dao.mapper;

import org.apache.ibatis.jdbc.SQL;
import test.serverframe.armc.server.manager.domain.LinkParam;

public class LinkParamSqlProvider {

    public String insertSelective(LinkParam record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("tb_ssgp_link_param");

        if (record.getLinkParamId() != null) {
            sql.VALUES("link_param_id", "#{linkParamId,jdbcType=VARCHAR}");
        }

        if (record.getInterRelateTaskId() != null) {
            sql.VALUES("inter_relate_task_id", "#{interRelateTaskId,jdbcType=VARCHAR}");
        }

        if (record.getInHeader() != null) {
            sql.VALUES("in_header", "#{inHeader,jdbcType=CLOB}");
        }

        if (record.getInBody() != null) {
            sql.VALUES("in_body", "#{inBody,jdbcType=CLOB}");
        }

        if (record.getInQuery() != null) {
            sql.VALUES("in_query", "#{inQuery,jdbcType=CLOB}");
        }

        if (record.getOutValue() != null) {
            sql.VALUES("out_value", "#{outValue,jdbcType=CLOB}");
        }

        if (record.getExceptionSign() != null) {
            sql.VALUES("exception_sign", "#{exceptionSign,jdbcType=INTEGER}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LinkParam record) {
        SQL sql = new SQL();
        sql.UPDATE("tb_ssgp_link_param");

        if (record.getInterRelateTaskId() != null) {
            sql.SET("inter_relate_task_id = #{interRelateTaskId,jdbcType=VARCHAR}");
        }

        if (record.getInHeader() != null) {
            sql.SET("in_header = #{inHeader,jdbcType=CLOB}");
        }

        if (record.getInBody() != null) {
            sql.SET("in_body = #{inBody,jdbcType=CLOB}");
        }

        if (record.getInQuery() != null) {
            sql.SET("in_query = #{inQuery,jdbcType=CLOB}");
        }

        if (record.getOutValue() != null) {
            sql.SET("out_value = #{outValue,jdbcType=CLOB}");
        }

        if (record.getExceptionSign() != null) {
            sql.SET("exception_sign = #{exceptionSign,jdbcType=INTEGER}");
        }

        sql.WHERE("link_param_id = #{linkParamId,jdbcType=VARCHAR}");

        return sql.toString();
    }
}
